#include <Transform.h>


/************************************/
/*              Members             */
/************************************/

    /************************************/
    /*          Constructors            */
    /************************************/

        Transform::Transform()
        {
            m_Forward =  vec4(0.0,0.0,-1.0,1.0);
        }

    /************************************/
    /*              Methods             */
    /************************************/

        void Transform::UpdateTransformMatrix()
        {
             m_TransformMatrix= m_RotationMatrix*m_PositionMatrix;
        }

        void Transform::Translate(float x, float y, float z)
        {
            m_Position = vec4(m_Position.x+x, m_Position.y+y, m_Position.z+z, 1.0);
            m_PositionMatrix = Matrix4::Translation(m_Position.x, m_Position.y, m_Position.z);
            UpdateTransformMatrix();
        }

        void Transform::Translation(float x, float y, float z)
        {
            m_Position= vec4(x, y, z, 1.0);
            m_PositionMatrix = Matrix4::Translation(m_Position.x, m_Position.y, m_Position.z);
            UpdateTransformMatrix();
        }

        void Transform::RotationEuler(float x, float y, float z)
        {
            m_EulerAngles = vec4(x,y,z,1.0);
            m_RotationMatrix= (Quaternion::Euler(m_EulerAngles.x,m_EulerAngles.y,m_EulerAngles.z)).RotationMatrix();
            UpdateTransformMatrix();
        }

        void Transform::RotateEuler(float x, float y, float z)
        {
            m_EulerAngles = vec4(m_EulerAngles.x+x,m_EulerAngles.y+y,m_EulerAngles.z+z,1.0);
            m_RotationMatrix= (Quaternion::Euler(m_EulerAngles.x,m_EulerAngles.y,m_EulerAngles.z)).RotationMatrix();
            UpdateTransformMatrix();
        }

        void Transform::RotateAroundAxis(float x, float y, float z, float teta)
        {
            Quaternion quat(x,y,z,teta);
            m_RotationMatrix=quat.RotationMatrix();
            UpdateTransformMatrix();
        }


        Matrix4 Transform::ReturnModelMatrix()
        {
            return m_TransformMatrix;
        }

        void Transform::Clear()
        {
            m_Position.Zero();
            m_EulerAngles.Zero();
        }



